import datetime
import time

from selenium import webdriver

from ..common.ui.Selector import Selector
from .DatetimePicker import DatetimePicker

import pytest


def test_setValue():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/datetimepicker/index.html")
    time.sleep(2)
    try:
        datetimepicker = DatetimePicker(browser, 'datetimepicker', Selector.ID)
        now_time = datetime.datetime.now()
        setdate = (now_time + datetime.timedelta(days=+1)).strftime("%Y-%m-%d %H:%M:%S")
        datetimepicker.setValue(setdate)
        time.sleep(2)
    finally:
        browser.close()

def test_setValue_now():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/datetimepicker/index.html")
    time.sleep(2)
    try:
        datetimepicker = DatetimePicker(browser, 'datetimepicker', Selector.ID)
        datetimepicker.setValue('now')
        time.sleep(2)
    finally:
        browser.close()


if __name__ == '__main__':
    pytest.main(['-s','DatetimePicker_test.py'])